<?php

Class baseController {

/*
 * @registry object
 */
protected $registry;

function __construct($registry) {
	$this->registry = $registry;
}

/**
 * @all controllers must contain an index method
 */
    public function master($body){
        if(!isset($_SESSION['username'])){
            $userModule = $this->registry->template->getTemplate("login", array());
        }else{
            $userModule = $this->registry->template->getTemplate("logout", array("username" => $_SESSION['username']));
        }


        $array_css  = null;
        $array_js   = null;
        $css        = "";
        $js         = "";
        if(checkMode()){
             $array_css = $this->registry->db->getManager("configManager")->cssmin;
             $array_js  = $this->registry->db->getManager("configManager")->jsmin;

        }else{
            $array_css = $this->registry->db->getManager("configManager")->css;
            $array_js  = $this->registry->db->getManager("configManager")->js;
        }

        foreach($array_css as $i){
            $css .= '<link type="text/css" rel="stylesheet" href="'.__SERVER.'/views/css/'.$i.'"/>
    ';
        }
        foreach($array_js as $i){
            $js .= '<script type="text/javascript" src="'.__SERVER.'/views/js/'.$i.'"></script>
';
        }




        $tags = array(
            "user"        => $userModule,
            "header"      => $this->registry->template->getTemplate("header", array()),
            "mmenu"       => $this->registry->template->getTemplate("mmenu", array()),
            "body"        => $body,
            "css"         => $css,
            "js"          => $js,
        );
        echo $this->registry->template->getTemplate("masterView", $tags);
    }

function index(){//must be, abstract function

}
}

?>
